package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.RingHrvInfo;
import com.ruoyi.ring.service.IRingHrvInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 心率变异性历史心率
 * 
 * @author liuwp
 * @date 2025-08-22
 */
@RestController
@RequestMapping("/ring/ring_hrv_Info")
public class RingHrvInfoController extends BaseController
{
    @Autowired
    private IRingHrvInfoService ringHrvInfoService;

    /**
     * 查询心率变异性历史心率列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_hrv_Info:list')")
    @GetMapping("/list")
    public TableDataInfo list(RingHrvInfo ringHrvInfo)
    {
        startPage();
        List<RingHrvInfo> list = ringHrvInfoService.selectRingHrvInfoList(ringHrvInfo);
        return getDataTable(list);
    }

    /**
     * 导出心率变异性历史心率列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_hrv_Info:export')")
    @Log(title = "心率变异性历史心率", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RingHrvInfo ringHrvInfo)
    {
        List<RingHrvInfo> list = ringHrvInfoService.selectRingHrvInfoList(ringHrvInfo);
        ExcelUtil<RingHrvInfo> util = new ExcelUtil<RingHrvInfo>(RingHrvInfo.class);
        util.exportExcel(response, list, "心率变异性历史心率数据");
    }

    /**
     * 获取心率变异性历史心率详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_hrv_Info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ringHrvInfoService.selectRingHrvInfoById(id));
    }

    /**
     * 新增心率变异性历史心率
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_hrv_Info:add')")
    @Log(title = "心率变异性历史心率", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RingHrvInfo ringHrvInfo)
    {
        return toAjax(ringHrvInfoService.insertRingHrvInfo(ringHrvInfo));
    }

    /**
     * 修改心率变异性历史心率
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_hrv_Info:edit')")
    @Log(title = "心率变异性历史心率", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RingHrvInfo ringHrvInfo)
    {
        return toAjax(ringHrvInfoService.updateRingHrvInfo(ringHrvInfo));
    }

    /**
     * 删除心率变异性历史心率
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_hrv_Info:remove')")
    @Log(title = "心率变异性历史心率", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ringHrvInfoService.deleteRingHrvInfoByIds(ids));
    }

}
